﻿Public Class perFormaProposta
    Inherits perAcessoBD

    Public Sub inserirFormaProposta(ByVal iCodProposta As Int32,
                                    ByVal iRevProposta As Int32,
                                    ByVal iCodRegiao As Int32,
                                    ByVal sCodProduto As String,
                                    ByVal sDescForma As String,
                                    ByVal dValor As Decimal,
                                    ByVal bDiluida As Boolean)
        Dim sSql As String

        sSql = "INSERT INTO proposta_formas" & Environment.NewLine &
               "           (codProposta" & Environment.NewLine &
               "           ,revProposta" & Environment.NewLine &
               "           ,codRegiao" & Environment.NewLine &
               "           ,codProduto" & Environment.NewLine &
               "           ,descForma" & Environment.NewLine &
               "           ,valorForma" & Environment.NewLine &
               "           ,diluida)" & Environment.NewLine &
               "        VALUES" & Environment.NewLine &
               "           (@codProposta" & Environment.NewLine &
               "           ,@revProposta" & Environment.NewLine &
               "           ,@codRegiao" & Environment.NewLine &
               "           ,@codProduto" & Environment.NewLine &
               "           ,@descForma" & Environment.NewLine &
               "           ,@valorForma" & Environment.NewLine &
               "           ,@diluida)"
        With MyBase.SQLCmd.Parameters
            .Clear()
            .AddWithValue("@codProposta", iCodProposta)
            .AddWithValue("@revProposta", iRevProposta)
            .AddWithValue("@codRegiao", iCodRegiao)
            .AddWithValue("@codProduto", sCodProduto)
            .AddWithValue("@descForma", sDescForma)
            .AddWithValue("@valorForma", dValor)
            .AddWithValue("@diluida", bDiluida)
        End With

        MyBase.executarAcao(sSql)

    End Sub

    Public Function retornarFormaProposta(ByVal iCodProposta As Int32, ByVal iRevProposta As Int32) As DataTable
        Dim sSql As String

        sSql = "SELECT codProposta" & Environment.NewLine &
               "      ,revProposta" & Environment.NewLine &
               "      ,codRegiao" & Environment.NewLine &
               "      ,codProduto" & Environment.NewLine &
               "      ,descForma" & Environment.NewLine &
               "      ,valorForma" & Environment.NewLine &
               "      ,diluida" & Environment.NewLine &
               " FROM proposta_formas " & Environment.NewLine &
               " WHERE proposta_formas.codProposta = @codProposta" & Environment.NewLine &
               "   AND proposta_formas.revProposta = @revProposta"

        With MyBase.SQLCmd.Parameters
            .Clear()
            .AddWithValue("codProposta", iCodProposta)
            .AddWithValue("revProposta", iRevProposta)
        End With

        Return MyBase.executarConsulta(sSql)

    End Function

End Class
